package com.dsl.tms.mapper.wmsdb;

import com.dsl.tms.entity.wmsdb.DwEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.ArrayList;

@Mapper
public interface DwMapper {

    @Select(value = "SELECT storerkey,company, store_second_name, " +
            " CASE WHEN type = '5' THEN '1' ELSE '2' END ssa_sign," +
            " store_name10, address1, 'Y' is_hospital" +
            " FROM storer" +
            " WHERE type IN ('2', '5')  AND store_second_name LIKE '%医院'" +
            " AND ycflag = '1'" +
            " UNION" +
            " SELECT storerkey,company, store_second_name, " +
            " CASE WHEN type = '5' THEN '1' ELSE '2' END ssa_sign," +
            " store_name10, address1, 'N' is_hospital" +
            " FROM storer" +
            " WHERE type IN ('2', '5')  AND (store_second_name NOT LIKE '%医院' OR" +
            " TRIM(store_second_name) IS NULL)" +
            " AND ycflag = '1'")
    @Results({
            @Result(column = "storerkey",property = "ssa_no"),
            @Result(column = "store_second_name",property = "ssa_name"),
            @Result(column = "ssa_sign",property = "ssa_sign"),
            @Result(column = "store_name10",property = "mnemonic_code"),
            @Result(column = "address1",property = "address"),
            @Result(column = "is_hospital",property = "is_hospital")
    })
    public ArrayList<DwEntity> queryDw();
}
